package com.hksj.Intelligentmanagement.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hksj.Intelligentmanagement.common.Rest;
import com.hksj.Intelligentmanagement.dto.AnesthesiaDTO;
import com.hksj.Intelligentmanagement.dto.NurseLevelDTO;
import com.hksj.Intelligentmanagement.service.AnesthesiaService;
import com.hksj.Intelligentmanagement.vo.AnesthesiaVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "麻醉人员信息管理")
//@RestController
@RequestMapping("/api/nurseLevel")
@Deprecated
public class AnesthesiaControllerOld {
    @Autowired
    private AnesthesiaService anesthesiaService;

    @ApiOperation("新增麻醉人员信息")
    @PostMapping("/createAnesthesia")
    public Rest createAnesthesia(@RequestBody @Validated(AnesthesiaDTO.Create.class) AnesthesiaDTO anesthesiaDTO){
        return anesthesiaService.create(anesthesiaDTO);
    }

    @ApiOperation("修改麻醉人员信息")
    @PostMapping("/updateAnesthesia")
    public Rest updateAnesthesia(@RequestBody @Validated(NurseLevelDTO.Update.class) AnesthesiaDTO anesthesiaDTO){
        return anesthesiaService.updateAnesthesia(anesthesiaDTO);
    }

    @ApiOperation("删除麻醉人员信息")
    @DeleteMapping("/deleteAnesthesia/{id}")
    public Rest deleteAnesthesia(@PathVariable("id") String id){
        return anesthesiaService.delete(id);
    }

    @ApiOperation("查询麻醉人员信息列表")
    @PostMapping("/listAnesthesia")
    public Rest<List<AnesthesiaVo>> listAnesthesia(@RequestBody AnesthesiaDTO anesthesiaDTO){
        return Rest.ok(anesthesiaService.listAnesthesia(anesthesiaDTO));
    }

    @ApiOperation("分页查询麻醉人员信息列表")
    @PostMapping("/pageAnesthesia")
    public Rest<IPage<AnesthesiaVo>> pageAnesthesia(
        @ApiParam(value = "麻醉医生姓名",required = false) @RequestParam(required = false) String anesthesiaName,
        @ApiParam(value = "麻醉医生工号",required = false) @RequestParam(required = false) String employeeNumber,
        @ApiParam(value = "状态(0:未禁用,1:已禁用)",required = false) @RequestParam(required = false) String status,
        @ApiParam(value = "起始页",required = false,defaultValue = "1") @RequestParam(required = false,defaultValue = "1") Integer pageNum,
        @ApiParam(value = "每页大小",required = false,defaultValue = "10") @RequestParam(required = false,defaultValue = "10") Integer pageSize){
        IPage<AnesthesiaVo> pageInfo = anesthesiaService.pageAnesthesia(new Page<>(pageNum,pageSize),anesthesiaName,employeeNumber,status);
        return Rest.ok(pageInfo);
    }
}
